<script type="text/javascript">
$(document).ready(function(){
	$(".buy a").click(function(){
		$.ajax({
			url: "<?php echo $this->url(array("action" => "add"), "cart"); ?>",
			data: "pid="+ $(this).attr("href"),
			type: "POST",
			dataType: "html",
			success: function(data){
				if(confirm("Sản phẩm đã được cho vào giỏ hàng.\nBạn có muốn xem giỏ hàng của bạn không?"))
						location.href = "<?php echo $this->url(array(), "cart");?>"	;
			}
		});
		return false;
	});
	$("#frmSearch").submit(function(){
		var keyword = $("#keyword").attr("value");
		if( keyword == '' || keyword == "Tìm sản phẩm..."){
			alert("Bạn cần nhập từ khóa tìm kiếm!");
			return false;
		}
	});
	
	

		
		$(".lv_top").append("<div id='navigator'>"+
								"<img id='btnNext' src='<?php echo PUBLIC_URL."/skins/default/images/image_next.png";?>' alt='Next'/>"+
								"<img id='btnPrev' src='<?php echo PUBLIC_URL."/skins/default/images/image_prev.png";?>' alt='Prev'/>"+
								"</div>").hover(function(){check();},function(){$("#btnNext, #btnPrev").hide();});

	$("#btnNext").click(function(){
		var displayed = $("#images img.displayed");
		displayed.removeClass("displayed");
		displayed.next().addClass("displayed");
		check();
	});
	$("#btnPrev").click(function(){
		var displayed = $("#images img.displayed");
		displayed.removeClass("displayed");
		displayed.prev().addClass("displayed");
		check();
	});
	$(".element_controll_button").click(function(){
		$(".element_controll_button.displayed").removeClass("displayed");
		$(".content_external_info_view.displayed").removeClass("displayed");
		$(this).addClass("displayed");
		$("#"+$(this).attr("id")+"_content").addClass("displayed");
	});
	
});
function check(){
	var images = $("#images img");
	var index = $("#images img.displayed").index();
	if(images.length > 1){
		if(index == 0){
			$("#btnPrev").css("display", "none");
			$("#btnNext").css("display", "block");
		}else if(index == images.length -1){
			$("#btnPrev").css("display", "block");
			$("#btnNext").css("display", "none");
		}else{
			$("#btnPrev").css("display", "block");
			$("#btnNext").css("display", "block");
		}
	}
}
</script>
<div id="main_content">
			<div id="top">
                <div id="contact_banner">
                	<?php Helper_HtmlRender::renderImageOrFlash($this->banners[2]->image, 723, 76, 'Thiết bị văn phòng Cường Phú')?>
                </div>
            </div><!-- end top main_content block-->
			<div id="view_product_box">
            	<div id="title_view_product_box"><?php echo $this->product->name;?></div>
                <div id="left_view">
                	<div class="lv_top">
						<div id="images">
							<?php 
							$arrImages = explode('@', $this->product->image);
							for($i = 0; $i < count($arrImages); $i++){
								if($arrImages[$i] !=''){
								if($i == 0) echo "<img class='displayed' src='".$arrImages[$i]."' alt=''/>";
								else echo "<img src='".$arrImages[$i]."' alt=''/>";
								}
							}
							?>
						</div>
						
					</div>
					<div class="lv_bottom">
						<span>Hỗ trợ miễn phí: Giao hàng và lắp đặt tại nơi sử dụng (Hà Nội)</span>
					</div>
					
                </div>
                <div id="right_view">
                	<div class="rv_top">
                		<?php echo $this->product->description;?>
                	</div>
                	<div class="rv_bottom">
						<div id="price_box"><?php echo number_format($this->product->price);?> VNĐ</div>
	                    <div class="action_button">
		                    <a target="_blank" href="<?php echo $this->url(array(), "print");?>?p=<?php echo $this->product->slug?>">
		                    	<img src="<?php echo PUBLIC_URL."/skins/default/images/print_button_03.jpg"?>" alt="Print"/>
		                    </a>
	                    </div>
	                   	<div class="buy action_button">
		                    <a href="<?php echo $this->product->id;?>">
		                    	<img src="<?php echo PUBLIC_URL."/skins/default/images/buy_button_03.jpg"?>" alt="Buy"/>
		                    </a>
	                	</div>
	                </div>
				</div>
            </div>
            <div class="space_block">
            	<?php echo Helper_HtmlRender::renderImageOrFlash($this->banners[8]->image, 719, 56, 'Thiết bị văn phòng Cường Phú');?>
            	
            </div>
            <div id="external_info_view">
            	<div id="controll_button">
                	<div id="specification" class="element_controll_button displayed">Chi tiết đặc tính</div>
                    <div id="ink" class="element_controll_button">Mực cho máy</div>
                    <div id="components" class="element_controll_button">Linh kiện cho máy</div>
					<div id="download" class="element_controll_button">Hỗ trợ tải file</div>
                </div>
                <div class="content_external_info_view displayed" id="specification_content">
                	<div class="ceiv_title">Chi tiết kỹ thuật</div>
                	<?php echo $this->product->specification;?>
                </div>
                <div class="content_external_info_view" id="ink_content">
                	<div class="ceiv_title">Thông tin về mực in</div>
                	<?php echo $this->product->ink;?>
                </div>
                <div class="content_external_info_view" id="components_content">
                	<div class="ceiv_title">Thông tin linh kiện</div>
                	<?php echo $this->product->components;?>
                </div>
                <div class="content_external_info_view" id="download_content">
                	<div class="ceiv_title">Hỗ trợ download</div>
                </div>
            </div>
</div><!-- end main_content block -->
        <div id="right">
        	<div id="search_box">
        		<form id="frmSearch" action="<?php echo $this->url(array(), "search");?>" method="get">
        			<input type="text" onclick="value='';"  id="keyword" name="keyword" value="Tìm sản phẩm..."/>
                	<input type="submit" id="submit_button" value="Tìm kiếm" />
        		</form>
            	
            </div><!-- end search_block-->
            <div id="cart_box">
            	<div id="title_cart"><a href="<?php echo $this->url(array(),"cart");?>">Giỏ hàng của bạn</a></div>
                <div class="cart_info">
                	<span class="left_info">Số sản phẩm:&nbsp; </span>
                    <span class="right_info"><?php echo $this->totalCartProduct;?></span>
                </div>
                <div class="cart_info">
                	<span class="left_info">Tổng tiền:&nbsp;</span>
                    <span class="right_info"><?php echo number_format($this->totalCartPrice);?> VND</span>
                </div>
            </div> <!-- end cart_block -->
            <?php
            //lấy dữ liệu để điền vào 2 box hỗ trợ trực tuyến
            $arrSalers = array();
            $arrTechnicians = array(); 
            foreach ($this->supporters as $supporter){
            	if($supporter->type == 0){
            		$arrSalers[] = $supporter;
            	}else{
            		$arrTechnicians[] = $supporter;
            	}
            }
            
                  
            ?>
           <div class="right_box">
            	<div class="title_box">
                	<div class="text_title_box">Bán hàng trực tuyến</div>
                    <div class="phone_title_box">(04) 35 68 36 99</div>
                </div>
                <?php $count_business =count($arrSalers);
               	if($count_business>0){
               	for( $i=0;$i<$count_business;$i++){?>
               	 <div class="supporter">
                	<div class="info_supporter">
                    	<div class="name_supporter">
                        	<a href="ymsgr:SendIM?<?php echo $arrSalers[$i]->yahoo_account;?>"  title="Contact to supporter!">
         						<?php echo $arrSalers[$i]->name;?>
                            </a>
                            </div>
                       	<div class="phone_supporter"><?php echo $arrSalers[$i]->phone;?></div>
                        <div class="email_supporter"><?php echo $arrSalers[$i]->email;?></div>
                        
                    </div>
                    <a href="ymsgr:SendIM?<?php echo $arrSalers[$i]->yahoo_account;?>"  title="Contact to supporter!">
                            <img  alt="" src="http://opi.yahoo.com/online?u=<?php echo $arrSalers[$i]->yahoo_account;?>&m=g&t=1" border="0"/>
                        </a>
                    <?php if($i+2 <= $count_business){?><div class="line"></div><?php } ?>
                </div>
               <?php }
               	 } ?>
                
               
            </div><!-- end right_box-->           
            <div class="right_box">
            	<div class="title_box">
                	<div class="text_title_box">Hỗ trợ kỹ thuật</div>
                    <div class="phone_title_box">(04) 66 84 87 86</div>
                </div>
                <?php $count_technical =count($arrTechnicians);
               	if($count_technical>0){
               	for( $i=0;$i<$count_technical;$i++){?>
               	 <div class="supporter">
                	<div class="info_supporter">
                    	<div class="name_supporter">
                        	<a href="ymsgr:SendIM?<?php echo $arrTechnicians[$i]->yahoo_account;?>"  title="Contact to supporter!">
         						<?php echo $arrTechnicians[$i]->name;?>
                            </a>
                            </div>
                        <div class="phone_supporter"><?php echo $arrTechnicians[$i]->phone;?></div>
                        <div class="email_supporter"><?php echo $arrTechnicians[$i]->email;?></div>
                        
                    </div>
                    <a href="ymsgr:SendIM?<?php echo $arrTechnicians[$i]->yahoo_account;?>"  title="Contact to supporter!">
                            <img  alt="" src="http://opi.yahoo.com/online?u=<?php echo $arrTechnicians[$i]->yahoo_account;?>&m=g&t=1" border="0"/>
                        </a>
                    <?php if($i+2 <= $count_technical){?><div class="line"></div><?php } ?>
                </div>
               <?php }
               	 } ?>
            </div><!-- end right_box-->
            <div class="right_box">
            	<div class="title_box">
                	<div class="text_title_box">Sản phẩm cùng loại</div>                    
                </div>
                <?php
                foreach($this->relateProducts as $relateProduct){
                	$arrRelateImages = explode('@', $relateProduct->image);
                ?>
                <div class="product_in_view">
	        		<div class="image_product">
						<a href="<?php echo $this->url(array("slug" => $relateProduct->slug),"product");?>">
						<?php 
		                	if(extension_loaded("gd") && function_exists("exec") ){ 
		                ?>
							<img src="<?php echo PUBLIC_URL.'/plugins/phpThumb/phpThumb.php?src='.$arrRelateImages[0].'&amp;w=134&amp;h=99'?>" /> 	
						<?php }else{?>
							<img src="<?php echo $arrRelateImages[0]?>" width="134px" height="99px" />
						<?php }?>
						</a>
	        			
	        		</div>
    	    	    <div class="decription_product">
    	    	    	<a href="<?php echo $this->url(array("slug" => $relateProduct->slug), "product");?>"><?php echo $relateProduct->name;?></a>
    	    	    </div>
	                <div class="price_product"><?php echo number_format($relateProduct->price);?></div>
                   	<div class="action">
                		<div class="buy"><a href="<?php echo $relateProduct->id;?>">Mua</a></div>
                        <div class="show_detail"><a href="<?php echo $this->url(array('slug' => $relateProduct->slug), 'product');?>">Chi tiết</a></div>

                   	</div>
	           		<div class="model_product"><?php echo $relateProduct->model;?></div>
	           		 	
              </div><!--end product block -->
                
              <?php }?>
              <div class="view_all"><a href="<?php echo $this->url(array("page"=>"", 'cat_id' => $this->relateCategory->id, 'cat_name' => Helper_Converter::stringToSlug($this->relateCategory->name)),'pcategory');?>">Xem tất cả&gt;&gt;&gt;</a></div>
              
            </div><!-- end right_box-->
                        <?php
            echo $this->partial("include/tags.phtml", array("tags" => $this->tags));
            ?>
        </div><!-- end right block -->
        <div id="clear"></div>